#ifndef SOFTWARE_SERIAL_H_
#define SOFTWARE_SERIAL_H_
#include <stdint.h>
#include <legacymsp430.h>

#define BUFF_SIZE 4
#define SMCLK_SPEED 1000000
#define TX_PIN 0x02
#define RX_PIN 0x04


typedef struct 
{
   uint8_t mData[BUFF_SIZE];
   uint8_t mHeadPtr;
   uint8_t mTailPtr;
} UartTxBuffer_s;

typedef struct 
{
   uint8_t mData[BUFF_SIZE];
   uint8_t mHeadPtr;
   uint8_t mTailPtr;
} UartRxBuffer_s;

#define RX_NOTEMPTY 0x01
#define RX_OVERFLOW 0x02
#define RxBufferEmpty ((gRxBuffer.mHeadPtr > gRxBuffer.mTailPtr) ? -1 : 1)

//Initialize the Timer Rx and Tx
// args:
// - Baud_rate in bps [onlt test at 9600]
// return:
//  void
void Uart_TimerA_Init(int baud_rate);

//Add 1 byte to the transmit queue
// args:
// - Byte to be sent over uart
// return:
//  -1 if buffer full else 0 for success
int Uart_Tx_Byte(uint8_t byte);
//Add a buffer to the transmit queue
// args:
// - Buffer of bytes to send
// - size of the buffer
// return:
//  number of bytes sent, -1 for error
int Uart_Tx_Buffer(uint8_t* buffer, uint8_t size);

#endif
